var ajax = {
    get: function (requrl, reqdata, reqback) {
        $.ajax({
            url: requrl,
            type: "GET",
            data: reqdata,
            success: function (json, status, xhr) {
                if (reqback)
                    reqback(json, xhr);
            },
            error: function(jqXHR, textStatus, errorThrown) {
              console.log(jqXHR, textStatus, errorThrown);
          }
        });
    },
    post: function (requrl, reqdata, reqback) {
        $.ajax({
            url: requrl,
            type: "POST",
            data: reqdata,
            dataType: 'json',
            success: function (json, status, xhr) {
                if (reqback)
                    reqback(json, xhr);
            },
        });
    },
    post2: function (requrl, reqdata, reqback) {
        $.ajax({
            url: requrl,
            type: "POST",
            data: JSON.stringify(reqdata),
            // data: reqdata,
            dataType: 'json',
            contentType: 'application/json',
            async:false,
            success: function (json, status, xhr) {
                if (reqback)
                    reqback(json, xhr);
            },
        });
    },
    del: function (requrl, reqdata, reqback) {
      $.ajax({
          url: requrl,
          type: "DELETE",
          data: reqdata,
//          dataType:'JSONP',
          success: function (json, status, xhr) {
              if (reqback)
                  reqback(json, xhr);
          },
          error: function(jqXHR, textStatus, errorThrown) {
              console.log(jqXHR, textStatus, errorThrown);
          }
      });
  }
}

/**
 * 取得URL传参
 * @param param
 * @returns {*}
 */
function getParameter(param)
{
    var query = window.location.search;
    var iLen = param.length;
    var iStart = query.indexOf(param);
    if (iStart == -1)
        return "";
    iStart += iLen + 1;
    var iEnd = query.indexOf("&", iStart);
    if (iEnd == -1)
        return query.substring(iStart);
    return query.substring(iStart, iEnd);
}